/**
 * Created by Administrator on 2015/9/6.
 */
var express = require('express');
var router = express.Router();
var adminService = require('../src/service/adminService');

/**跳转到更新用户信息界面*/
router.get('/personalSetting/toUpdatePersonInfo', function (req, res, next) {
    res.render('EJS/admin/personalSetting/updatePersonInfo', {title: '个人信息修改',users: 1,user: req.session.currentUser});
});
/**更新用户信息*/
router.post('/personalSetting/updatePersonInfo', function (req, res, next) {
    adminService.updatePersonInfo(req, res, function (a) {
        var obj1=eval(a);
        res.render('EJS/admin/personalSetting/updatePersonInfo', {title: '个人信息修改', users:obj1.code,user:req.session.currentUser});
    })
});
/**检查手机号码是否重复*/
router.post('/personalSetting/checkTel', function (req, res, next) {
    adminService.queryTel(req, res, function (a) {
        var obj1 = eval(a);
        res.send(obj1);
    })
});
/**跳转到修改用户密码界面*/
router.get('/personalSetting/toUpdatePassword', function (req, res, next) {
    res.render('EJS/admin/personalSetting/updatePassword', {title: '修改用户密码',r_code:1});
});
/**验证用户密码*/
router.post('/personalSetting/checkPassword', function (req, res, next) {
    adminService.queryPassword(req, res, function (a) {
        var obj1 = eval(a);
        //console.log(obj1.code);
        res.send(obj1);
    })
});
/**修改用户密码*/
router.post('/personalSetting/updatePassword', function (req, res, next) {
    adminService.updatePassword(req, res, function (a) {
        var obj1 = eval(a);
        console.log(obj1.code);
        res.render('EJS/admin/personalSetting/updatePassword', {title: '修改用户密码',r_code:obj1.code});
    })
});

module.exports = router;